﻿namespace Xms.Abp;

public class ExceptionNotificationService : TextWriter
{
    private TextWriter _decorated;
    public override Encoding Encoding => Encoding.UTF8;

    public event EventHandler<string> OnException;

    public ExceptionNotificationService()
    {
        _decorated = Console.Error;
        Console.SetError(this);
    }

    public override void WriteLine(string value)
    {
        OnException?.Invoke(this, value);

        _decorated.WriteLine(value);
    }
}
